package com.niit.servlet;

import com.niit.pojo.StudentTable;
import com.niit.service.HbaseService;
import com.niit.service.impl.HbaseServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @author 杨铭
 * @date 2022/2/9 8:56
 **/
@WebServlet("/displayServlet")
public class displayServlet extends HttpServlet {

    public void init(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String endRow = req.getParameter("endRow");
        HbaseService hbaseService = new HbaseServiceImpl();
        List<StudentTable> studentTables = hbaseService.scanByPage(endRow);
        System.out.println(studentTables);
        req.setAttribute("StudentByPage", studentTables);
        req.getRequestDispatcher("/pages/displayPage.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
